package com.helen.ui;

import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.helen.shopping.R;
import com.helen.utils.StatusBarUtil;

import butterknife.BindView;

/**
 * Created by yang on 2018/5/15.
 */

public class TestActivity extends BaseActivity {
    @BindView(R.id.iv_girl)
    ImageView ivGirl;
    @BindView(R.id.toolbar_title)
    TextView tvTitle;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.collapsingToolbarLayout)
    CollapsingToolbarLayout collapsingToolbarLayout;
    @BindView(R.id.appBarLayout)
    AppBarLayout appBarLayout;

    @Override
    protected int attachLayoutRes() {
        return R.layout.test;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initViews() {
        StatusBarUtil.setTranslucentForImageViewInFragment(TestActivity.this, null);
        initToolBar();
    }

    @Override
    protected void updateViews() {

    }


    private void initToolBar() {
//        collapsingToolbarLayout.setTitle("");
//        toolbar.setTitle("");
        tvTitle.setText("title");
        collapsingToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.transparent));//设置还没收缩时状态下字体颜色
        collapsingToolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.transparent));//设置收缩后Toolbar上字体的颜色
        appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBar, int offset) {
                tvTitle.setAlpha(Math.abs(offset * 1f / appBar.getTotalScrollRange()));
            }
        });
    }

}
